# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Contributor: Natanael Copa <ncopa@alpinelinux.org>
# Maintainer: fossdd <fossdd@pwned.life>
pkgname=cgit-pink
pkgver=1.4.1
pkgrel=0
_gitver=2.36.1
pkgdesc="web frontend for git"
url="https://git.causal.agency/cgit-pink/"
arch="all"
license="GPL-2.0-or-later"
makedepends="
	openssl-dev>3
	zlib-dev
	lua5.3-dev
	asciidoc
	"
subpackages="$pkgname-doc"
source="https://git.causal.agency/cgit-pink/snapshot/cgit-pink-$pkgver.tar.gz
	https://www.kernel.org/pub/software/scm/git/git-$_gitver.tar.gz
	"
options="!check"

_makeopts="NO_ICONV=YesPlease
	NO_GETTEXT=YesPlease
	NO_TCLTK=YesPlease
	NO_SVN_TESTS=YesPlease
	NO_REGEX=NeedsStartEnd
	LUA_PKGCONFIG=lua5.3
	prefix=/usr"

prepare() {
	# check that upstream git ver corresponds with our
	local _ver=$(awk -F'[ \t]*=[ \t]*' '/^GIT_VER/ { print $2 }' Makefile)
	if [ "$_ver" != "$_gitver" ]; then
		error "Please set _gitver in APKBUILD to $_ver"
		return 1
	fi

	rm -rf git
	mv ../git-$_gitver git

	default_prepare
}

build() {
	make $_makeopts all doc-man
}

package() {
	make $_makeopts DESTDIR="$pkgdir" \
		CGIT_SCRIPT_PATH=/usr/share/webapps/cgit \
		install install-man
	ln -s cgit.cgi "$pkgdir"/usr/share/webapps/cgit/cgit
}

sha512sums="
a4fe07bb45eda81360fabe8fa4232b31af126c95085fee8ff858ba0dc99f97a5eaee76d0d7bd487383c20a991043f0c87770ef1981b4c800d768783623e7eb71  cgit-pink-1.4.1.tar.gz
2ce8fb5f68fa0e228fde75218f49928ccfaf89ce932ba3a432231be67f28be41c5736059a9ab59d4fbe0e034ea656e6e31b339c3837b2303373e3490b8841ba6  git-2.36.1.tar.gz
"
